<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class buku_besar extends My_Controller
{
	
	function __construct()
	{
		parent::__construct();
		$this->load->model('mdl_buku_besar', 'buku_besar');
		$this->load->library('pdf');
		$this->load->library('fungsi');
	}
	
	function index()
	{
		$this->open();
		
		# config pagination
		$config['base_url'] = base_url().'index.php/buku_besar/index/';
		
		$this->pagination->initialize($config);	
		# end config pagination
		
		# get data
		//$data['results'] = $this->buku_besar->getItem($config['per_page'], $this->uri->segment(3));
		
		# load view
		$this->load->view('buku_besar/form_buku_besar_periode');
		
		$this->close();
	}
	
	
	function form_buku_kas_periode(){
		$this->open();
		$this->load->view('buku_besar/form_buku_kas_periode');
		$this->close();
	}
	
	
	function view_buku_kas_periode(){
				$periode_awal = $this->uri->segment('3');		$periode_akhir = $this->uri->segment('4');		$akun = $this->uri->segment('5');				
		
		if (($periode_awal)&&($periode_akhir)){		
			$data['periode_awal']=$periode_awal;
			$data['periode_akhir']=$periode_akhir;			$datenow=date('Y');
			$data['results'] = $this->buku_besar->getItem_periode($periode_awal,$periode_akhir, $akun);			$data_saldo_akun_awal = $this->buku_besar->get_saldo_awal_akun($akun);			$data['saldo_akun_awal']= $data_saldo_akun_awal->row()->jumlah;						$data['akun'] = $akun;
			$this->load->view('buku_besar/view_buku_besar_periode', $data);
		}
	}
	
	function report_pdf(){
		$periode_awal = $this->uri->segment('3');
		$periode_akhir = $this->uri->segment('4');
		$data['periode_awal']=$this->fungsi->dateindo3('-',$periode_awal);
		$data['periode_akhir']=$this->fungsi->dateindo3('-',$periode_akhir);		$datenow=date('Y');		$data['results'] = $this->buku_besar->getItem_periode($periode_awal,$periode_akhir, $akun);		$data['akun'] = $akun;		//$this->load->view('buku_besar/view_buku_kas_periode', $data, true);
        $html = $this->load->view('buku_besar/pdf_buku_besar_periode', $data, true);
        $this->pdf->pdf_create($html, 'buku_besar','letter','landscape');
	}
	
	function report_excel(){
		header("Content-type: application/x-msdownload");
		header("Content-Disposition: attachment; filename=rekap_buku_kas_periode.xls");
		echo  $this->input->post('rekap_tabel1');
	}


}